<?php
	
	if (!isset($v_paging_item_name)) $v_paging_item_name = " M&#7849;u tin ";
	if(!isset($v_this_page_url)){
		$v_this_page_url = "?".$_SERVER['QUERY_STRING'];
		$v_this_page_url = explode("&hdn_offset=",$v_this_page_url);
		$v_this_page_url = $v_this_page_url[0];
	}
	$v_num_page_per_line = 4;
	if (!isset($v_number_of_all_result))  $v_number_of_all_result = 0;
	if (!isset($v_num_row))  $v_num_row = 20;
	if ($v_number_of_all_result){
	if ($v_number_of_all_result>$v_num_row){
		$v_total_page = ceil(($v_number_of_all_result / $v_num_row));		
		$v_current_page = (int)($v_offset/$v_num_row+1);
		echo '
		<table width="100%" border=0 ><tr>
		<td class="paging_total" style="font-size:12px;">C&#243;: '.$v_number_of_all_result.' '.$v_paging_item_name.' (Trong '.$v_total_page.' trang)</td>
		';
		if ($v_current_page>$v_num_page_per_line){
			$v_start_page = $v_current_page - $v_num_page_per_line;
			if ($v_total_page>$v_current_page + $v_num_page_per_line){
				$v_end_page = $v_current_page + $v_num_page_per_line;
			}else{
				$v_end_page = $v_total_page;
			}
		}else{
			$v_start_page =1;
			if ($v_total_page<$v_num_page_per_line*2){
				$v_end_page = $v_total_page;
			}else{
				$v_end_page = $v_num_page_per_line*2;
			}	
		}
		if($v_start_page>1){
			echo '<td width = 15 class="paging" ><A href = "'.$v_this_page_url.'&hdn_offset=0"><</A></td>';
		}
		
		for ($i = $v_start_page; $i <= $v_end_page;$i++){
			if ($i==$v_current_page){
				echo "<td width = 15 class=\"paging_selected\"><b>".$i."</b></td>";
			}else{
				echo '<td width = 15 class="paging"><A href = "'.$v_this_page_url.'&hdn_offset='.($i-1)*$v_num_row.'">'.$i.'</A></td>';
			}
		}
		if($v_current_page<$v_total_page && $v_end_page < $v_total_page){
			echo '<td class="paging" ><A href = "'.$v_this_page_url.'&hdn_offset='.($v_total_page-1)*$v_num_row.'">></A></td>';
		}
		
		echo '</tr></table>';
	}else {
		echo '
		<table width="100%" border=0 ><tr>
		<td class="paging_total" style="font-size:12px;">C&#243;: '.$v_number_of_all_result.' '.$v_paging_item_name.' (Trong 1 trang)</td>
		';
		echo '</tr></table>';		
	}
}
?>
